package com.simple.microservices.web.active;

import com.simple.microservices.api.active.BlindBoxService;
import com.simple.microservices.commons.utils.Response;
import com.simple.microservices.dao.dataobject.Spot;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author hyf
 * @date 2021/10/11
 */
@RestController
@RequestMapping("/active/miss/spot")
public class SpotController {

    @Resource
    private BlindBoxService blindBoxService;

    /**
     * 放入纸条
     * @return
     */
    @PostMapping("/putSpot")
    @ResponseBody
    public Response putSpot(@RequestBody Spot spot){

        // 保存数据
        blindBoxService.putSpotByUserId(spot.getUserId());

        return Response.success();
    }
    /**
     * 保存添加/修改的数据
     */
    @PostMapping("/saveSpot")
    @ResponseBody
    public Response saveSpot( @RequestBody Spot spot) {
         blindBoxService.saveSpot(spot);
        return Response.success();
    }
    /**
     * 是否已提交小纸条
     * @return
     */
    @GetMapping("/putSpotStatus")
    @ResponseBody
    public Response putSpotStatus(){

        Boolean flag = blindBoxService.getByUserId();
        return Response.success(flag);
    }

}